/**
 * @brief    CTRIA6六节点三角形词条解析单元测试
 * 
 * @version  0.1
 * @author   Liu Xing
 * @date     2025.10.20
 * @copyright Copyright (c) 2025
 */

#include "Import/BDFImport/BulkData/Element/CTRIA6Parser.h"

#include "gtest/gtest.h"

#include "DataStructure/Common/Constant.h"
#include "DataStructure/Input/Element/CTRIA6Data.h"

#include "DBManager/DBServiceFactory.h"
#include "DBManager/IService/Input/Element/IElementService.h"

#include "Import/BDFImport/BDFParserBase.h"

using namespace SG::DBManager;
using namespace SG::Import;
using SG::DataStructure::Common::TOLERANCE;
using namespace SG::DataStructure::FEM;
extern std::shared_ptr<DBServiceFactory> DB_SERVICEFACTORY;
extern std::vector<std::string>          dividedEntryInfo;

class CTRIA6ParserTest : public ::testing::Test
{
  public:
    static void SetUpTestSuite ()
    {
        DB_SERVICEFACTORY->ClearDatabase ();
    }
};

TEST_F (CTRIA6ParserTest, ParseEntry1)
{
    std::vector<std::string> Entry = { "CTRIA6     10001       1   10202   10025   10040   10013   10014   10015" };
    BDF::divideBulkEntry (Entry, dividedEntryInfo);
    SG::Import::BDF::BULKDATA::ParseCTRIA6 (DB_SERVICEFACTORY, dividedEntryInfo);
    SG::DataStructure::FEM::CTRIA6Data data;

    DB_SERVICEFACTORY->get<IElementService> ()->FindByIndex (0, data);

    ASSERT_TRUE (data.m_id == 10001);
    ASSERT_TRUE (data.m_pId == 1);
    ASSERT_TRUE (data.m_g[0] == 10202);
    ASSERT_TRUE (data.m_g[1] == 10025);
    ASSERT_TRUE (data.m_g[2] == 10040);
    ASSERT_TRUE (data.m_g[3] == 10013);
    ASSERT_TRUE (data.m_g[4] == 10014);
    ASSERT_TRUE (data.m_g[5] == 10015);    
    ASSERT_NEAR (data.m_theta, 0., TOLERANCE);
    ASSERT_NEAR (data.m_zoffs, 0., TOLERANCE);
    ASSERT_TRUE (data.m_tflag == false);
    ASSERT_TRUE (data.m_theta == 0);
}